import request from '@u/request'
import request8080 from '@u/request8080'
import qs from 'qs'
const UserModule = 'system'
export function login(loginForm) {
  return request.post(`${UserModule}/user/login`, qs.stringify(loginForm), {
    headers: {
      // "Content-Type": "multipart/form-data",
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}
export function getUserList(pageQuery) {
  return request.get(`${UserModule}/user/query`, {
    params: {
      ...pageQuery,
    },
  })
}

// 删除用户
export function deleteUser(pkid) {
  return request.delete(`${UserModule}/user/delete`, {
    params: {
      pkid,
    },
  })
}

// 编辑角色
export function updateUser(pkid, data) {
  return request.put(`${UserModule}/user/update/${pkid}`, JSON.stringify(data))
}

// 添加用户
export function addUser(data) {
  return request.post(`${UserModule}/user/add`, JSON.stringify(data))
}
// 获取社区级联数据
export function getCommunityCascaderList(params) {
  return request({
    method: 'get',
    url: '/city-insp/admin-catalog/get',
    params,
  })
}
export function getRoleList(pageQuery) {
  return request.get(`${UserModule}/role/query`, {
    params: {
      ...pageQuery,
    },
  })
}
// 获取部门树
export function getDepartmentTree() {
  return request.get(`${UserModule}/department/getDepartmentTree`)
}
// 添加
// export function addUser(data) {
//     return request({
//       method: 'post',
//       url: '/city-insp/user-mgmt/add',
//       data,
//     })
//   }
// 获取列表
// export function getUserList(params) {
//     return request({
//       method: 'get',
//       url: '/city-insp/user-mgmt/list',
//       params,
//     })
//   }
// 编辑列表
export function editUser(data) {
  return request({
    method: 'post',
    url: '/city-insp/user-mgmt/edit',
    data,
  })
}
// 编辑列表
// export function deleteUser(params) {
//     return request({
//       method: 'get',
//       url: '/city-insp/user-mgmt/del',
//       params,
//     })
//   }

export function statistics(params) {
  return request8080({
    method: 'post',
    url: 'query',
    headers: {
      'Content-Type': 'application/json',
    },
    data: JSON.stringify(params),
  })
}
